package jdly.water.api.controller.cost;

import java.util.LinkedHashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import jdly.water.api.common.service.R;
import jdly.water.api.model.PageModel;
import jdly.water.api.service.cost.CostService;

@RestController
@RequestMapping("/account")
public class AccountController {

	@Autowired
	private CostService costService;

	@GetMapping("/list")
	@ResponseBody
	public R userlist(String meternumber, String orgname, String building, String unit, String room, PageModel page) {
		LinkedHashMap param = new LinkedHashMap();
		param.put("meter.meterNumber", meternumber);
		param.put("meter.building.org.orgname", orgname);
		param.put("meter.building.floor", building);
		param.put("meter.building.unit", unit);
		param.put("meter.building.room", room);
		return costService.userlist(param, null, page);
	}
	
	@GetMapping("/get")
	@ResponseBody
	public R get(String id) {
		R r  = costService.userinfo(id);
		return r;
	}
	
	
	@GetMapping("/payrecord")
	@ResponseBody
	public R payrecord(String id) {
		R r  = costService.paylist(id);
		return r;
	}
	
	
	@GetMapping("/balancelist")
	@ResponseBody
	public R balancelist(String id) {
		R r  = costService.balancelist(id);
		return r;
	}
	
//	
//	@GetMapping("/detail")
//	@ResponseBody
//	public R detail(String meternumber, String orgname, String building, String unit, String room,String month,String year,PageModel page) {
//		LinkedHashMap param = new LinkedHashMap();
//		param.put("meter.meterNumber", meternumber);
//		param.put("meter.building.org.orgname", orgname);
//		param.put("meter.building.floor", building);
//		param.put("meter.building.unit", unit);
//		param.put("meter.building.room", room);
//		param.put("month", Integer.valueOf(month));
//		param.put("year",Integer.valueOf(year));
//		R r  = costService.detailist(param,page);
//		return r;
//	}
	@GetMapping("/detail")
	@ResponseBody
	public R detail(String id) {
		R  r = R.ok();
		r = costService.detaillist(id);
		return r;
		
	}
	
	
	
}
